<?php

use yii\db\Migration;

class m160930_091722_add_wx_msg_log_table extends Migration
{
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=Myisam';
        }

        $this->createTable('mkt_msg_log', [
            'id' => $this->primaryKey(),
            'ToUserName' => $this->string(64)->notNull(),
            'FromUserName' => $this->string(64)->notNull(),
            'CreateTime' => $this->integer(),
            'MsgType' => $this->string(),
            'WholeMsg' => $this->string(1024),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
            'elapsetime' => $this->float()
        ], $tableOptions);
    }

    public function down()
    {
        $this->dropTable('mkt_msg_log');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
